package com.flower.utils;

import java.util.Random;

/**
 * 验证码 构造工具类
 */
public class ItUtil {

    /**
     * 由于工具类无需创建对象，所以把其构造器私有化
     */
    private ItUtil(){

    }
    public static String createVerifyCode(int n) {
        String code = "";
        String data = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        Random r = new Random();
        for (int i = 0; i < n; i++) {
            int index = r.nextInt(data.length());
            code += data.charAt(index);
        }
        return code;
    }

    public static void main(String[] args) {
        String verifyCode = createVerifyCode(6);
        System.out.println(verifyCode.toLowerCase());
        System.out.println(verifyCode.toUpperCase());
    }
}
